<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>

<script type="text/javascript">
$(document).ready(function() {
    $('#userTable').dataTable();
} );
</script>
<div style="margin-top: 5px; margin-bottom: 15px">
<h2 style="display: inline"><s:text name="listUsers.header"></s:text></h2>
<div style="float: right">
<s:if test="#session.loginToken.rights.contains('user_create')">
	<s:url id="createUserInputUrlId" action="createUserInput" namespace="/"></s:url>
	<s:a href="%{createUserInputUrlId}">
		<img src="image/icons/0009_add.png" width="24" height="24" alt="new"
			border="0" title="Neuen User erstellen">
	</s:a>
</s:if>
</div>
</div>
<table id="userTable" class="green">
	<thead>
		<tr>
			<th>ID</th>
			<th><s:text name="userBean.firstName"></s:text></th>
			<th><s:text name="userBean.lastName"></s:text></th>
			<th><s:text name="userBean.email"></s:text></th>
			<th><s:text name="listUsers.status"></s:text></th>
			<th><s:text name="listUsers.action"></s:text></th>
		</tr>
	</thead>
	<tbody>
		<s:iterator value="userList">
			<tr>
				<td><s:property value="userId"></s:property></td>
				<td><s:property value="firstName"></s:property></td>
				<td><s:property value="lastName"></s:property></td>
				<td><s:property value="email"></s:property></td>
				<td><%--Status (Rolle Admin bekommt goldene Medaille --%> <s:if
					test="roleList.contains('admin')">
					<img src="image/icons/0041_medal_gold.png" width="24" height="24"
						alt="admin" border="0" title="Administrator">
				</s:if> <%--Icon für Aktivieren / Deaktivieren --%> <s:if
					test="%{isActive == false}">
					<s:url id="activateUrlId" action="activateUser" namespace="/">
						<s:param name="userId">
							<s:property value="userId"></s:property>
						</s:param>
					</s:url>
					<s:if test="#session.loginToken.rights.contains('user_activate')">
						<s:a href="%{activateUrlId}">
							<img src="image/icons/0008_minus.png" width="24" height="24"
								alt="act" border="0" title="Klicken zum aktivieren">
						</s:a>
					</s:if>
					<s:else>
						<img src="image/icons/0008_minus.png" width="24" height="24"
							alt="deact" border="0" title="Deaktiviert">
					</s:else>
				</s:if> <s:else>
					<s:url id="deactivateUrlId" action="deactivateUser" namespace="/">
						<s:param name="userId">
							<s:property value="userId"></s:property>
						</s:param>
					</s:url>
					<s:if test="#session.loginToken.rights.contains('user_activate')">
						<s:a href="%{deactivateUrlId}">
							<img src="image/icons/0007_tick.png" width="24" height="24"
								alt="deact" border="0" title="Klicken zum deaktivieren">
						</s:a>
					</s:if>
					<s:else>
						<img src="image/icons/0007_tick.png" width="24" height="24"
							alt="act" border="0" title="Aktiviert">
					</s:else>
				</s:else></td>
				<td><%--Icon für Profil ansehen --%> <s:if
					test="#session.loginToken.rights.contains('user_list')">
					<s:url id="profileUrlId" action="profileInput" namespace="/">
						<s:param name="userId">
							<s:property value="userId"></s:property>
						</s:param>
					</s:url>
					<s:a href="%{profileUrlId}">
						<img src="image/icons/0047_id.png" width="24" height="24"
							alt="profile" border="0" title="Profil ansehen">
					</s:a>
				</s:if> <%--Icon für Profil bearbeiten --%> <s:if
					test="#session.loginToken.rights.contains('user_edit')">
					<s:url id="editUrlId" action="editProfileInput" namespace="/">
						<s:param name="userId">
							<s:property value="userId"></s:property>
						</s:param>
					</s:url>
					<s:a href="%{editUrlId}">
						<img src="image/icons/0037_notepad.png" width="24" height="24"
							alt="edit" border="0" title="Profil bearbeiten">
					</s:a>
				</s:if> <%--Icon für Löschen --%> <s:if
					test="#session.loginToken.rights.contains('user_delete')">
					<s:url id="deleteUrlId" action="deleteUser" namespace="/">
						<s:param name="userId">
							<s:property value="userId"></s:property>
						</s:param>
					</s:url>
					<s:a href="%{deleteUrlId}">
						<img src="image/icons/0049_trash.png" width="24" height="24"
							alt="del" border="0" title="Löschen" onclick="return ask_first(this);">
					</s:a>
				</s:if> <%--Icon für Passwort zurücksetzen --%> <s:if
					test="#session.loginToken.rights.contains('user_reset_password')">
					<s:url id="resetPwUrlId" action="resetPassword" namespace="/">
						<s:param name="userId">
							<s:property value="userId"></s:property>
						</s:param>
					</s:url>
					<s:a href="%{resetPwUrlId}">
						<img src="image/icons/0027_key.png" width="24" height="24"
							alt="reset pw" border="0" title="Passwort zurücksetzen" onclick="return ask_first(this,'Passwort wirklich zurücksetzen?');">
					</s:a>
				</s:if></td>
			</tr>
		</s:iterator>
	</tbody>
</table>